#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QFile>
#include <QTextStream>
Widget::Widget(int currentID, QString &role, QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    this->role = role;
    this->currentID = currentID;
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
    delete db;
}

void Widget::on_pushButton_clicked()
{
    QString height = ui->lineEdit->text();
        QString weight = ui->lineEdit_2->text();
        QString heartRate = ui->lineEdit_3->text();
        QString bloodPressure = ui->lineEdit_4->text();
        QString vitalCapacity = ui->lineEdit_5->text();

        db = new DatabaseHandler();
        db->connectToDatabase(DATABASE_PATH);

        QSqlQuery query;
        QDate currentDate = QDate::currentDate();
        QString date = currentDate.toString("yyyy-MM-dd");
        QString assessment = "ok";

        int patientID = this->currentID; // 假设的 PatientID

        // 构建完整的 SQL 查询字符串
        QString sql = QString("INSERT INTO HealthAssessments (PatientID, Assessment, Date) VALUES (%1, '%2', datetime('now'))")
                        .arg(patientID)
                        .arg(assessment);
        tcp = new ClientTcp(INSERT_DATA);
        tcp->sendMsg(sql);

}

void Widget::on_pushButton_2_clicked()
{
}
